<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{

    public function up(): void
    {
        Schema::create('menus', function (Blueprint $table) {
            $table->id()->comment('主键id');
            $table->unsignedBigInteger('parentId')->default(0)->comment('父菜单ID');
            $table->string('name', 100)->comment('菜单名称');
            $table->tinyInteger('visible')->default(1)->comment('是否可见(1-是 0-否)');
            $table->string('icon', 100)->nullable()->comment('ICON');
            $table->integer('sort')->default(0)->comment('排序');
            $table->string('routeName', 100)->nullable()->comment('路由名称');
            $table->string('routePath', 200)->nullable()->comment('路由路径');
            $table->string('component', 200)->nullable()->comment('组件路径');
            $table->string('redirect', 200)->nullable()->comment('跳转路由路径');
            $table->tinyInteger('type')->nullable()->comment('菜单类型(1-菜单 2-目录 3-外链 4-按钮)');
            $table->string('perm', 100)->nullable()->comment('权限标识');
            $table->tinyInteger('keepAlive')->nullable()->comment('是否缓存(1-是 0-否)');
            $table->tinyInteger('alwaysShow')->nullable()->comment('【目录】只有一个子路由是否始终显示(1-是 0-否)');
            $table->json('params')->nullable()->comment('路由参数');
            $table->timestamp('createTime')->nullable()->comment('创建时间（秒级时间戳）');
            $table->timestamp('updateTime')->nullable()->comment('更新时间（秒级时间戳）');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('menus');
    }
};
